import diyApi from '@/api/declaration/mall/diyApi'
import httpRequest from '@/config/axios/httpRequest'
import { DiyTemplateModel, DiyTemplatePropertyModel } from '@/models/mall/DiyTemplateModel'

// 查询装修模板列表
export const getDiyTemplatePage = async (params: any) => {
  return await httpRequest.get(diyApi.GetDiyTemplatePage, { params })
}

// 查询装修模板详情
export const getDiyTemplate = async (id: number) => {
  return await httpRequest.get<DiyTemplateModel>(diyApi.GetDiyTemplate, { params: { id } })
}

// 新增装修模板
export const createDiyTemplate = async (data: DiyTemplateModel) => {
  return await httpRequest.post(diyApi.CreateDiyTemplate, data)
}

// 修改装修模板
export const updateDiyTemplate = async (data: DiyTemplateModel) => {
  return await httpRequest.put(diyApi.UpdateDiyTemplate, data)
}

// 删除装修模板
export const deleteDiyTemplate = async (id: number) => {
  return await httpRequest.delete(diyApi.DeleteDiyTemplate, { params: { id } })
}

// 使用装修模板
export const useDiyTemplate = async (id: number) => {
  return await httpRequest.put(diyApi.UseDiyTemplate, { id })
}

// 获得装修模板属性
export const getDiyTemplateProperty = async (id: number) => {
  return await httpRequest.get<DiyTemplatePropertyModel>(diyApi.GetDiyTemplateProperty, {
    params: { id }
  })
}

// 更新装修模板属性
export const updateDiyTemplateProperty = async (data: DiyTemplateModel) => {
  return await httpRequest.put(diyApi.UpdateDiyTemplateProperty, data)
}
